import { defineStore, acceptHMRUpdate } from 'pinia'
import { getSidebarStatus, setSidebarSatus } from '@/utils/index'

export const useAppStore = defineStore('app', {
    state: () => (
        {
            //左侧菜单展开
            sidebar: getSidebarStatus(),
            // 系统是否全屏
            screenful: false,
        }
    ),
    getters: {
        sidebarWidth: (state) => state.sidebar ? '200px' : '64px'
    },
    actions: {
        //切换侧边菜单
        changeSidebar() {
            this.sidebar = !this.sidebar
            setSidebarSatus(this.sidebar)
        },
        changeScreenful() {
            this.screenful = !this.screenful
        }

    }

})

if (import.meta.hot) {
    import.meta.hot.accept(acceptHMRUpdate(useAppStore, import.meta.hot))

}